Skip to content

[mosaic] Avoid shrinking vectorized write batches after short inputs - #11434

Open
jianguotian wants to merge 1 commit into
apache:masterfrom
jianguotian:upstream/mosaic-vectorized-short-inputs
Open

jianguotian wants to merge 1 commit into
apache:masterfrom
jianguotian:upstream/mosaic-vectorized-short-inputs

Conversation

@jianguotian

@jianguotian jianguotian commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Short input tails currently lower MosaicRecordsWriter's adaptive batch target even when memory is sufficient. After a one-row input, the next input starts with only two rows and has to grow again, causing unnecessary Arrow conversion/export and native write calls.

Preserve the learned target when the successful slice was limited by the remaining input rows. Continue to apply the measured memory bound and configured batch-size cap. Initial sizing, gradual growth, allocation-failure retries and per-slice flushing remain unchanged.

Only the existing Mosaic writer and its column-batch test change; no new API, configuration or dependency is required.

Tests

  • A regression test reproduces the old tail-driven fragmentation and verifies batch sizes and output values after the fix.
  • All 152 Mosaic tests passed on JDK 8 with native Mosaic 0.3.0, including memory limits, skewed values, allocator exhaustion, selections and native round trips.

Compaction performance

Measured on ARM64 with the released Mosaic 0.3.0 JNI library, cached local files, default batch settings and the VIN bitmap enabled. Both versions used vectorized execution and differed only in the writer change. Times are medians of six measured runs per version across two JVMs, with one warmup per JVM. Native writes were counted separately.

Input files Base median PR median Change in time Native writes (base → PR)
24 × 150 rows (copies of one sample) 8.884 s 6.223 s −30.0% 56 → 27
3 distinct files of 600 rows each 1.732 s 1.680 s −3.0% 8 → 8
4 distinct files of 600 / 600 / 69 / 600 rows 2.157 s 1.965 s −8.9% 11 → 9
7 distinct files, 66,658 rows total 10.565 s 10.682 s +1.1% Not measured

The three short-file fixtures had 11,371 logical fields. Every run preserved all values, row order and exact VIN bitmap positions. The 24 × 150-row fixture exercises the short-tail boundary. On the 8,700-field large-file fixture, the timing ranges overlapped. Full decoding matched the input, and all 16 output files had identical SHA-256 hashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant